#include <bits/stdc++.h>
using namespace std;

int di[8] = {0, 0, 1, -1, 1, 1, -1, -1};
int dj[8] = {1, -1, 0, 0, 1, -1, 1, -1};

int main() {
  char bong[101][101];
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> bong[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (bong[i][j] == '*') {
        continue;
      }
      int sum = 0;
      for (int k = 0; k < 8; k++) {
        int x = i + di[k];
        int y = j + dj[k];
        if (bong[x][y] == '*') {
          sum++;
        }
      }
      bong[i][j] = sum + '0';
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << bong[i][j];
    }
    cout << endl;
  }
  return 0;
}